package cn.tedu.charging.order.config;

import lombok.extern.slf4j.Slf4j;
import org.hibernate.validator.HibernateValidator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.validation.Validation;
/**
 * 验证框架的配置
 * 体会快速失败
 */
@Slf4j
@Configuration
public class ValidationConfiguration {
    @Bean
    public javax.validation.Validator validator() {
        return Validation.byProvider(HibernateValidator.class)
                .configure()
                .failFast(true) //快速失败,一个检查不通过,就返回,不会继续检查
                .buildValidatorFactory()
                .getValidator();
    }
}
